Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Public Api for Register New Extensions for Rake Notes #14379

Merged
merged 8 commits into from Mar 17, 2014

Conversation

robertomiranda
Copy link
Contributor

ref #14214


# Registers new Annotations File Extensions
# SourceAnnotationExtractor::Annotation.register_extensions("css", "scss", "sass", "less", "js") { |tag| /\/\/\s*(#{tag}):?\s*(.*)$/ }
def self.regiter_extensions(*extensions, &block)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: regiter => register

@guilleiguaran
Copy link
Member

Please add tests

/cc @carlosantoniodasilva @rafaelfranca @senny

def self.directories
@@directories ||= %w(app config db lib test) + (ENV['SOURCE_ANNOTATION_DIRECTORIES'] || '').split(',')
end

def self.extensions
@@extensions ||= DEFAULT_EXTENSIONS

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you don't need defaults, you can just use the register method to create all defaults, wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good 👍

@senny
Copy link
Member

senny commented Mar 14, 2014

we will need test cases.

@robertomiranda
Copy link
Contributor Author

done, i guess 😄


register_extensions("builder", "rb", "rake") { |tag| /#\s*(#{tag}):?\s*(.*)$/ }
register_extensions("css", "js") { |tag| /\/\/\s*(#{tag}):?\s*(.*)$/ }
register_extensions("erb") { |tag| /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/ }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these all extensions supported by default? What about yml for example?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I removed all the extensions that can be added in the corresponding gems. I'm going to add the support for yml 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I missed up .ruby extension

@robin850 robin850 added this to the 4.2.0 milestone Mar 15, 2014
@robin850
Copy link
Member

@robertomiranda : Thanks for your contribution! It looks like your tests are failing though. Would you mind having a look ? Could you also add a changelog entry please ?

Also I don't know what do you guys think but I also thought about adding such feature for a while but at the railtie level. What do you think about providing a wrapper around SourceAnnotationExtractor::Annotation.register_extensions in railties' configuration like:

config.annotations.register_extensions("coffee") do
  /regex/
end

app_file "app/assets/javascripts/application.js", "// TODO: note in js"
app_file "app/assets/stylesheets/application.css", "// TODO: note in css"
app_file "app/assets/stylesheets/application.css.scss", "// TODO: note in scss"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep scss and sass

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, this will be sass-rails job.

@rafaelfranca
Copy link
Member

👍 for @robin850 idea.

@robertomiranda
Copy link
Contributor Author

@robin850 👍 for the wrapper. I'm going to review the tests

@robertomiranda
Copy link
Contributor Author

  • Tests Fixed
  • Changelog entry added
  • Config wrapper Done

@@ -1,3 +1,7 @@
* Add Public Api for Register New Extensions for Rake Notes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we update it to:

Add public API to register new extensions for rake notes.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to add an example on how to register new stuff, and maybe a guides update if we have something about rake notes in there.

@robertomiranda
Copy link
Contributor Author

All done

guilleiguaran added a commit that referenced this pull request Mar 17, 2014
Add Public Api for Register New Extensions for Rake Notes
@guilleiguaran guilleiguaran merged commit 4a69c93 into rails:master Mar 17, 2014
@guilleiguaran
Copy link
Member

Thanks!!!

@robertomiranda robertomiranda deleted the rake-notes.config branch March 17, 2014 22:47
@guilleiguaran
Copy link
Member

oops, next time please squash everything in a single commit, please 😁

@jeremy
Copy link
Member

jeremy commented Mar 17, 2014

+squash please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants